.\" -*- nroff -*-
.TH SAVELOG 8 "30 Dec 2017" "Debian"
.SH NAME
savelog \- save a log file
.SH SYNOPSIS
.B savelog
[\-m mode] [\-u user] [\-g group] [\-t] [\-p] [\-c cycle] [\-l] [\-j]
[\-J] [\-1\ .\|.\ \-9] [\-C] [\-d] [\-l] [\-r rolldir] [\-n] [\-q]
[\-D dateformat] file ...
.
.SH DESCRIPTION
The
.B savelog
command saves and optionally compresses old copies of files.  Older versions
of
.I file
are named:
.RS
.sp 1
.IR file "." <number> "" <compress_suffix>
.sp 1
.RE
where
.I <number>
is the version number, 0 being the newest.  Version numbers > 0 are compressed
unless
.B \-l
prevents it.  Version number 0 is not compressed because a process might still
have
.I file
opened for I/O.  Only
.I cycle
versions of the file are kept.
.sp 1
If the file does not exist and
.B \-t
was given, it will be created.
.sp 1
For files that do exist and have lengths greater than zero, the following
actions are performed:
.sp 1
.IP 1)
Version numbered files are cycled.  Version
.IB file \&.2
is moved to version
.IB file \&.3 \fR,
version
.IB file \&.1
is moved to version
.IB file \&.2 \fR,
and so on.  Finally version
.IB file \&.0
is moved to version
.IB file \&.1 \fR,
and version
.I file
is deleted.  Both
compressed names and uncompressed names are cycled, regardless of
.BR \-l .
Missing version files are ignored.
.
.IP 2)
The new
.IB file \&.1
is compressed unless the
.B \-l
flag was given.  It is changed subject to the
.BR "\-m" ", " "\-u" ", and " "\-g"
flags.
.
.IP 3)
The main
.I file
is moved to
.IB file .0 \fR.
.
.IP 4)
If the
.BR "\-m" ", " "\-u" ", " "\-g" ",  " "\-t" ", or " "\-p"
flags are given, then an empty
.I file
is created subject to the given flags.  With the
.B \-p
flag, the file is created with the same owner, group, and permissions as
before.
.
.IP 5)
The new
.IB file \&.0
is changed subject to the
.BR "\-m" ", " "\-u" ", and " "\-g"
flags.
.
.SH OPTIONS
.TP
.B "\-m mode"
chmod the log files to mode, implies
.B \-t
.TP
.B "\-u user"
chown log files to user, implies
.B \-t
.TP
.B "\-g group"
chgrp log files to group, implies
.B \-t
.TP
.B "\-c cycle"
Save cycle versions of the logfile (default: 7).
The
.I cycle
count must be at least 2.
.TP
.B \-t
touch new logfile into existence
.TP
.B \-l
don't compress any log files (default: do compress)
.TP
.B \-p
preserve owner, group, and permissions of logfile
.TP
.B \-j
compress with bzip2 instead of gzip
.TP
.B \-J
compress with xz instead of gzip
.sp 1
For xz no strength option is set,
and xz decides on the default based on the total amount of physical
RAM.
Note that xz can use a very large amount of memory for the higher
compression levels.
.TP
.B \-1\ .\|.\ \-9
compression strength or memory usage (default: 9, except for xz)
.TP
.B \-C
force cleanup of cycled logfiles
.TP
.B \-d
use standard date for rolling
.TP
.B "\-D dateformat"
override date format, in the syntax understood by the
.BR date (1)
command
.TP
.B \-r
use
.I rolldir
instead of \&.\& to roll files
.TP
.B \-n
do not rotate empty files
.TP
.B \-q
be quiet
.SH BUGS
If a process is still writing to
.IB file \&.0 \fR,
and savelog moves it to
.IB file \&.1
and compresses it, data could be lost.
.
.SH SEE ALSO
.BR logrotate (8)
